package com.example.rustfs.dao;

import com.example.rustfs.entity.UploadChunk;
import org.springframework.stereotype.Repository;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 分片上传数据访问层
 */
@Repository
public class UploadChunkDao {
    
    private final Map<String, UploadChunk> uploadChunks = new ConcurrentHashMap<>();
    
    public UploadChunk save(UploadChunk chunk) {
        uploadChunks.put(chunk.getUploadId(), chunk);
        return chunk;
    }
    
    public UploadChunk findByUploadId(String uploadId) {
        return uploadChunks.get(uploadId);
    }
    
    public void delete(String uploadId) {
        uploadChunks.remove(uploadId);
    }
}

